package MyStack;

import java.util.Arrays;

public class MyStack {
    public int[]elem;
    public int useSize=0;

    public MyStack() {
        this.elem =new int[10];
    }

    public int pop(){
        if(empty()){
           throw new StackemptyExpection("栈为空，无法出栈");
        }
        return elem[useSize--];
    }

    public void push(int val){
        if(isFull()){
            this.elem= Arrays.copyOf(elem,elem.length*2);
        }
elem[useSize]=val;
useSize++;
    }

    public int peek(){
return elem[useSize-1];
    }

    public boolean empty(){
return useSize==0;
    }

    public boolean isFull(){
        return useSize== elem.length;
    }

}
